package org.example.springmybatisdemo.mapper;


import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.springmybatisdemo.entity.CarOrder;
import org.example.springmybatisdemo.entity.CarUser;
//import org.example.springmybatisdemo.entity.Dept;
import org.example.springmybatisdemo.entity.Dept;
import org.example.springmybatisdemo.entity.User;

import java.util.List;

@Mapper // 作用: 将当前接口生成代理对象，并交给spring管理
public interface CarMapper {
    //    查询所有用户
    //    @Select("select * from users") // 注解 select查询 delete删除
    //    public List<User> list();

    @Select("select * from carusers where username = #{username} and password = #{password}")
     public List<CarUser> queryByusernameAndPassword(CarUser user);

    @Select("select * from carorders where user_id = #{userId}")
    public List<CarOrder> SelectOrderList(Integer userId);

    //    新增
    @Insert("insert into carorders(user_id, appointment_id, coupon_id, shop_name, address, contact_phone, order_content, total_price, actual_payment) values (#{userId}, #{appointmentId}, #{couponId}, #{shopName}, #{address}, #{contactPhone}, #{orderContent}, #{totalPrice}, #{actualPayment})")
    public int addOrder(CarOrder carorder);
}

